/**
 * 
 */
package com.wistech.search.solr.score;

import java.util.concurrent.locks.ReentrantLock;

import org.apache.solr.common.params.SolrParams;
import org.apache.solr.core.SolrConfig;
import org.apache.solr.schema.IndexSchema;

/**
 * 自定义评分器工厂类
 * 
 * @author Liuye
 * 
 */
public abstract class XscorerFactory {
	private IndexSchema schema;
	protected SolrConfig solrConfig;
	protected SolrParams params;
	protected String statusMessage;
	protected ReentrantLock importLock = new ReentrantLock();

	/**
	 * 初始化
	 * 
	 * @param solrConfig
	 * @param schema
	 * @param params
	 */
	public void init(SolrConfig solrConfig, IndexSchema schema,
			SolrParams params) {
		this.solrConfig = solrConfig;
		this.schema = schema;
		this.params = params;
	}

	public SolrParams getParams() {
		return params;
	}

	/**
	 * @return the statusMessage
	 */
	public String getStatusMessage() {
		return statusMessage;
	}

	public boolean isBusy() {
		return importLock.isLocked();
	}

	/**
	 * 获取xcorer
	 * 
	 * @return
	 */
	public abstract Xscorer getXscorer();

	/**
	 * 重新加载配置
	 */
	public abstract void reConfigure();

	/**
	 * 刷新评分数据
	 */
	public abstract void refresh();

	/**
	 * @return the outerExpression
	 */
	public abstract ScoreExpression getScoreExpression();

	/**
	 * @return the schema
	 */
	public IndexSchema getSchema() {
		return schema;
	}

	/**
	 * @return the solrConfig
	 */
	public SolrConfig getSolrConfig() {
		return solrConfig;
	}

}
